package com.intellagric.agriecom.service.recommend.service;

import com.github.pagehelper.PageHelper;
import com.intellagric.agriecom.module.recommend.RecommendColumnServiceIN;
import com.intellagric.mapper.RecommendColumnMapper;
import com.intellagric.pojo.RecommendColumn;
import com.intellagric.pojo.RecommendColumnExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther: zhy
 * @Date: 2019/5/10
 * @Description: 推荐栏位信息管理
 */
@Service
public class RecommendColumnService implements RecommendColumnServiceIN {


    @Autowired
    private RecommendColumnMapper recommendColumnMapper;

    /**
    * 添加推荐栏位信息
    * @param recommendColumn
    * @return int
    */
    public int addRecommendColumn(RecommendColumn recommendColumn) {
        return recommendColumnMapper.insertSelective(recommendColumn);
    }
    
    /**
     * 删除推荐栏位信息
     * @param id
     * @return int
     */
    public int deleteRecommendColumn(int id) {
        return recommendColumnMapper.deleteByPrimaryKey(id);
    }
    
    /**
     * 修改推荐栏位信息
     * @param
     * @return int
     */
    public int editRecommendColumn(RecommendColumn recommendColumn) {
        return recommendColumnMapper.updateByPrimaryKeySelective(recommendColumn);
    }
    
    /**
     * 通过id查询推荐栏位
     * @param id
     * @return RecommendColumn
     */
    public RecommendColumn queryRecommendColumnById(int id) {
        return recommendColumnMapper.selectByPrimaryKey(id);
    }
    
    /**
     * 查询所有推荐栏位信息
     * @return List<RecommendColumn>
     */
    public List<RecommendColumn> queryRecommendColumnList() {
        RecommendColumnExample RecommendColumnExample = new RecommendColumnExample();
        RecommendColumnExample.createCriteria().andIdIsNotNull();
        return recommendColumnMapper.selectByExample(RecommendColumnExample);
    }
    
    /**
     * 分页查询所有推荐栏位记录
     * @return List<RecommendColumn>
     */
    public List<RecommendColumn> queryRecommendColumnPage(int page,int rows) {
        PageHelper.startPage(page, rows);
        RecommendColumnExample RecommendColumnExample = new RecommendColumnExample();
        RecommendColumnExample.createCriteria().andIdIsNotNull();
        return recommendColumnMapper.selectByExample(RecommendColumnExample);
    }


}
